<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This file documents the use of the GNU compilers.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>ARM Function Attributes (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="ARM Function Attributes (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="ARM Function Attributes (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Function-Attributes.html" rel="up" title="Function Attributes">
<link href="AVR-Function-Attributes.html" rel="next" title="AVR Function Attributes">
<link href="ARC-Function-Attributes.html" rel="prev" title="ARC Function Attributes">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
kbd.key {font-style: normal}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en_US">
<div class="subsection-level-extent" id="ARM-Function-Attributes">
<div class="nav-panel">
<p>
Next: <a href="AVR-Function-Attributes.html" accesskey="n" rel="next">AVR Function Attributes</a>, Previous: <a href="ARC-Function-Attributes.html" accesskey="p" rel="prev">ARC Function Attributes</a>, Up: <a href="Function-Attributes.html" accesskey="u" rel="up">Declaring Attributes of Functions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="ARM-Function-Attributes-1"><span>6.33.5 ARM Function Attributes<a class="copiable-link" href="#ARM-Function-Attributes-1"> &para;</a></span></h4>

<p>These function attributes are supported for ARM targets:
</p>
<dl class="table">
<dt><a id="index-general_002dregs_002donly-function-attribute_002c-ARM"></a><span><code class="code">general-regs-only</code><a class="copiable-link" href="#index-general_002dregs_002donly-function-attribute_002c-ARM"> &para;</a></span></dt>
<dd><p>Indicates that no floating-point or Advanced SIMD registers should be
used when generating code for this function.  If the function explicitly
uses floating-point code, then the compiler gives an error.  This is
the same behavior as that of the command-line option
<samp class="option">-mgeneral-regs-only</samp>.
</p>
</dd>
<dt><a id="index-interrupt-function-attribute_002c-ARM"></a><span><code class="code">interrupt</code><a class="copiable-link" href="#index-interrupt-function-attribute_002c-ARM"> &para;</a></span></dt>
<dd><p>Use this attribute to indicate
that the specified function is an interrupt handler.  The compiler generates
function entry and exit sequences suitable for use in an interrupt handler
when this attribute is present.
</p>
<p>You can specify the kind of interrupt to be handled by
adding an optional parameter to the interrupt attribute like this:
</p>
<div class="example smallexample">
<pre class="example-preformatted">void f () __attribute__ ((interrupt (&quot;IRQ&quot;)));
</pre></div>

<p>Permissible values for this parameter are: <code class="code">IRQ</code>, <code class="code">FIQ</code>,
<code class="code">SWI</code>, <code class="code">ABORT</code> and <code class="code">UNDEF</code>.
</p>
<p>On ARMv7-M the interrupt type is ignored, and the attribute means the function
may be called with a word-aligned stack pointer.
</p>
</dd>
<dt><a id="index-isr-function-attribute_002c-ARM"></a><span><code class="code">isr</code><a class="copiable-link" href="#index-isr-function-attribute_002c-ARM"> &para;</a></span></dt>
<dd><p>Use this attribute on ARM to write Interrupt Service Routines. This is an
alias to the <code class="code">interrupt</code> attribute above.
</p>
</dd>
<dt><a class="index-entry-id" id="index-short_005fcall-function-attribute_002c-ARM"></a>
<a class="index-entry-id" id="index-indirect-calls_002c-ARM"></a>
<a id="index-long_005fcall-function-attribute_002c-ARM"></a><span><code class="code">long_call</code><a class="copiable-link" href="#index-long_005fcall-function-attribute_002c-ARM"> &para;</a></span></dt>
<dt><code class="code">short_call</code></dt>
<dd><p>These attributes specify how a particular function is called.
These attributes override the
<samp class="option">-mlong-calls</samp> (see <a class="pxref" href="ARM-Options.html">ARM Options</a>)
command-line switch and <code class="code">#pragma long_calls</code> settings.  For ARM, the
<code class="code">long_call</code> attribute indicates that the function might be far
away from the call site and require a different (more expensive)
calling sequence.   The <code class="code">short_call</code> attribute always places
the offset to the function from the call site into the &lsquo;<samp class="samp">BL</samp>&rsquo;
instruction directly.
</p>
</dd>
<dt><a id="index-naked-function-attribute_002c-ARM"></a><span><code class="code">naked</code><a class="copiable-link" href="#index-naked-function-attribute_002c-ARM"> &para;</a></span></dt>
<dd><p>This attribute allows the compiler to construct the
requisite function declaration, while allowing the body of the
function to be assembly code. The specified function will not have
prologue/epilogue sequences generated by the compiler. Only basic
<code class="code">asm</code> statements can safely be included in naked functions
(see <a class="pxref" href="Basic-Asm.html">Basic Asm &mdash; Assembler Instructions Without Operands</a>). While using extended <code class="code">asm</code> or a mixture of
basic <code class="code">asm</code> and C code may appear to work, they cannot be
depended upon to work reliably and are not supported.
</p>
</dd>
<dt><a id="index-pcs-function-attribute_002c-ARM"></a><span><code class="code">pcs</code><a class="copiable-link" href="#index-pcs-function-attribute_002c-ARM"> &para;</a></span></dt>
<dd>
<p>The <code class="code">pcs</code> attribute can be used to control the calling convention
used for a function on ARM.  The attribute takes an argument that specifies
the calling convention to use.
</p>
<p>When compiling using the AAPCS ABI (or a variant of it) then valid
values for the argument are <code class="code">&quot;aapcs&quot;</code> and <code class="code">&quot;aapcs-vfp&quot;</code>.  In
order to use a variant other than <code class="code">&quot;aapcs&quot;</code> then the compiler must
be permitted to use the appropriate co-processor registers (i.e., the
VFP registers must be available in order to use <code class="code">&quot;aapcs-vfp&quot;</code>).
For example,
</p>
<div class="example smallexample">
<pre class="example-preformatted">/* Argument passed in r0, and result returned in r0+r1.  */
double f2d (float) __attribute__((pcs(&quot;aapcs&quot;)));
</pre></div>

<p>Variadic functions always use the <code class="code">&quot;aapcs&quot;</code> calling convention and
the compiler rejects attempts to specify an alternative.
</p>
</dd>
<dt><a id="index-target-function-attribute-1"></a><span><code class="code">target (<var class="var">options</var>)</code><a class="copiable-link" href="#index-target-function-attribute-1"> &para;</a></span></dt>
<dd><p>As discussed in <a class="ref" href="Common-Function-Attributes.html">Common Function Attributes</a>, this attribute 
allows specification of target-specific compilation options.
</p>
<p>On ARM, the following options are allowed:
</p>
<dl class="table">
<dt><a id="index-target_0028_0022thumb_0022_0029-function-attribute_002c-ARM"></a><span>&lsquo;<samp class="samp">thumb</samp>&rsquo;<a class="copiable-link" href="#index-target_0028_0022thumb_0022_0029-function-attribute_002c-ARM"> &para;</a></span></dt>
<dd><p>Force code generation in the Thumb (T16/T32) ISA, depending on the
architecture level.
</p>
</dd>
<dt><a id="index-target_0028_0022arm_0022_0029-function-attribute_002c-ARM"></a><span>&lsquo;<samp class="samp">arm</samp>&rsquo;<a class="copiable-link" href="#index-target_0028_0022arm_0022_0029-function-attribute_002c-ARM"> &para;</a></span></dt>
<dd><p>Force code generation in the ARM (A32) ISA.
</p>
<p>Functions from different modes can be inlined in the caller&rsquo;s mode.
</p>
</dd>
<dt><a id="index-target_0028_0022fpu_003d_0022_0029-function-attribute_002c-ARM"></a><span>&lsquo;<samp class="samp">fpu=</samp>&rsquo;<a class="copiable-link" href="#index-target_0028_0022fpu_003d_0022_0029-function-attribute_002c-ARM"> &para;</a></span></dt>
<dd><p>Specifies the fpu for which to tune the performance of this function.
The behavior and permissible arguments are the same as for the <samp class="option">-mfpu=</samp>
command-line option.
</p>
</dd>
<dt><a id="index-arch_003d-function-attribute_002c-ARM"></a><span>&lsquo;<samp class="samp">arch=</samp>&rsquo;<a class="copiable-link" href="#index-arch_003d-function-attribute_002c-ARM"> &para;</a></span></dt>
<dd><p>Specifies the architecture version and architectural extensions to use
for this function.  The behavior and permissible arguments are the same as
for the <samp class="option">-march=</samp> command-line option.
</p>
<p>The above target attributes can be specified as follows:
</p>
<div class="example smallexample">
<pre class="example-preformatted">__attribute__((target(&quot;arch=armv8-a+crc&quot;)))
int
f (int a)
{
  return a + 5;
}
</pre></div>

<p>Additionally, the architectural extension string may be specified on its
own.  This can be used to turn on and off particular architectural extensions
without having to specify a particular architecture version or core.  Example:
</p>
<div class="example smallexample">
<pre class="example-preformatted">__attribute__((target(&quot;+crc+nocrypto&quot;)))
int
foo (int a)
{
  return a + 5;
}
</pre></div>

<p>In this example <code class="code">target(&quot;+crc+nocrypto&quot;)</code> enables the <code class="code">crc</code>
extension and disables the <code class="code">crypto</code> extension for the function <code class="code">foo</code>
without modifying an existing <samp class="option">-march=</samp> or <samp class="option">-mcpu</samp> option.
</p>
</dd>
</dl>

</dd>
</dl>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="AVR-Function-Attributes.html">AVR Function Attributes</a>, Previous: <a href="ARC-Function-Attributes.html">ARC Function Attributes</a>, Up: <a href="Function-Attributes.html">Declaring Attributes of Functions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
